home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / include / processStats.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  2.2 KB  |  82 lines

  1. #ifndef _PROCESSSTATS_H_
  2. #define _PROCESSSTATS_H_
  3. /*
  4.  *   $RCSfile: processStats.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:46 $      
  7.  */ 
  8. /*
  9.  * stats.h
  10.  *
  11.  * Class definition for the stats class.
  12.  * Member functions are defined in stats.c
  13.  */
  14. #ifndef  _stats
  15. #define  _stats
  16.  
  17. #include <stdio.h>
  18. #include "sysdefs.h"
  19. #include <sys/resource.h>
  20.  
  21. #ifdef hpux
  22. #include <sys/syscall.h>
  23. #define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
  24. #endif /* hpux */
  25.  
  26. /*
  27.  * Stats objects are meant to be used as follows:
  28.  *
  29.  *        statsObj.Start();
  30.  *        section of code for which stats are being gathered
  31.  *        statsObj.Stop();
  32.  *        examine gathered statistics
  33.  *
  34.  * Note that member functions marked as unimplmented return zero.
  35.  * They are unimplemented because Mach has yet to support the 
  36.  * gathering of the required statistics.
  37.  * Mach will supposedly provide support in the near future, however.
  38.  */
  39.  
  40.  
  41. /*
  42.  * Stats for Unix processes.
  43.  */
  44. class ProcessStats {
  45.     struct timeval  time1;        /* gettimeofday() buffer */
  46.     struct timeval  time2;        /* gettimeofday() buffer */
  47.     struct rusage   rusage1;    /* getrusage() buffer */
  48.     struct rusage   rusage2;    /* getrusage() buffer */
  49.  
  50.     int    smPagesRead1;
  51.     int    smPagesRead2;
  52.     int    smPagesWrite1;
  53.     int    smPagesWrite2;
  54.  
  55. public:
  56.     void   Start();            /* start gathering stats  */
  57.     void   Stop();            /* stop gathering stats  */
  58.     float  RealTime();        /* elapsed real time in micro-seconds */
  59.     float  UserTime();        /* elapsed user time in micro-seconds */
  60.     float  SystemTime();    /* elapsed system time in micro-seconds */
  61.     int    PageReclaims();    /* page reclaims */
  62.     int    PageFaults();    /* page faults */
  63.     int    Swaps();            /* swaps */
  64.     int    PageIns();        /* page-ins */
  65.     int    PageOuts();        /* page-outs */
  66.     int    smPagesRead();        /* pages read from sm */
  67.     int    smPagesWrite();        /* pages written to sm */
  68.     void   PrintStatsHeader(FILE *f);
  69.     void   PrintStats(FILE *f, char* prefix);
  70. };
  71.  
  72. /* 
  73.  * C library externs.
  74.  */
  75. #ifndef getrusage
  76. extern "C" int    getrusage(int, struct rusage*);
  77. #endif
  78. extern "C" int    gettimeofday(struct timeval*, struct timezone*);
  79.  
  80. #endif _stats
  81. #endif /* _PROCESSSTATS_H_ */
  82.